﻿using System;

using FireBus.Contracts;


namespace FireBus.Isolation
{
	public abstract class ExtensionAdapter : MarshalByRefObject
	{
		public ExtensionMetadata Metadata { get; internal set; }


		protected static void NotifyAll<TEvent>(NotifyEventArgs<TEvent> eventArgs)
			where TEvent : class
		{
			if (eventArgs == null)
			{
				throw new ArgumentNullException("eventArgs");
			}
			ExtensionController.NotifyAll(eventArgs.Arguments);
		}

		protected static void Send<TRequest, TResponse>(SendEventArgs<TRequest, TResponse> eventArgs)
			where TRequest : class
			where TResponse : class
		{
			if (eventArgs == null)
			{
				throw new ArgumentNullException("eventArgs");
			}
			ExtensionController.Send(eventArgs);
		}

		public override Object InitializeLifetimeService()
		{
			return null;
		}
	}
}
